import { useEffect, useRef, useState } from "react"
import * as echarts from 'echarts';

export default function BaseChart(props){

  const { options, config } = props

  const chartRef = useRef(null)
  
  useEffect(()=>{
    if(!options){return;}
    let inst = chartRef.current.instance
    if(!inst){
      inst = echarts.init(chartRef.current)
      chartRef.current.instance = inst
    }
    inst.setOption(options)
  }, [options])

  return <>
    <div ref={chartRef} style={{minHeight: '300px'}}>

    </div>
  </> 
}